package com.joe.test_mybatis_plus.controller;

import com.joe.test_mybatis_plus.entity.ExcelUser;
import com.joe.test_mybatis_plus.utils.ExcelUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
* @Description:    描述
* @Author:         Joe
* @CreateDate:     2023/4/22 20:10
*/
@RequestMapping(value = "/excel")
@RestController
public class ExcelController {

//    @GetMapping(path = "/downLoad")
//    public void downLoad(HttpServletResponse resp) throws Exception {
//        List<ExcelUser> list = new ArrayList<>();
//        ExcelUser user1 = new ExcelUser(1L, "妲己", 20, "17691279016");
//        list.add(user1);
//        ExcelUser user2 = new ExcelUser(2L, "李元芳", 21, "17691279017");
//        list.add(user2);
//        ExcelUtils.exportExcelToTarget(resp,"用户","用户", list, ExcelUser.class);
//    }

    public static void main(String[] args) throws ParseException {
        String s1 = dateToStamp("2023-05-15 00:00:00");
        System.out.println(s1);
        System.out.println("--------------------------------");
        String s = dateToStamp("2023-05-15 17:00:00");
        System.out.println(s);
    }

    public static String dateToStamp(String s) throws ParseException {
        String res;
        //设置时间模版
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date date = simpleDateFormat.parse(s);
        long ts = date.getTime();
        res = String.valueOf(ts);
        return res;
    }
}
